<?php

namespace Home\Controller;

use Utuo\ForegroundController;

class ArticleController extends ForegroundController {
	
	// 详细页
	public function showAction() {
		$d = D("ModelArticle");
		$id = I('id', 0, 'intval'); // 文章id
		$content = $d->detail(null, $id);
		$this->assign("content", $content['data']);
		$this->display($this->getTemplete($content['model']['tag'], 'content'));
	}
	
	// 更多
	public function moreAction() {
		$d = D("ModelArticle");
		$contentLists = $d->lists($this->catId, $paginate = true, $this->getPageSize(), $this->getPage());
		$totalPages = ceil($contentLists['count'] / $this->getPageSize()); //总页数
		$data = array();
		if($this->getPage() <= $totalPages) {
			$data = $contentLists['data'];
			foreach ($data as &$v){
				$v['url'] = get_content_url($contentLists['model']['tag'], $this->sid, $this->catId, $v['id']);
			}
		}
		$this->ajaxSuccess('', $data);
	}
	
}